package com.nbsaas.boot.product.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;

/**
 * 商品SKU实体
 * 用于管理商品的具体销售单元，包含价格和库存信息
 */
@Comment("商品SKU")
@Data
@FormAnnotation(title = "商品SKU管理", model = "商品SKU")
@Entity
@Table(name = "nb_product_sku")
public class ProductSku extends AbstractEntity {

    @Comment("SKU名称")
    @FormField(title = "SKU名称", grid = true, required = true)
    @Column(length = 100)
    private String name;


    @Comment("SKU编码")
    @FormField(title = "SKU编码", grid = true)
    @Column(length = 30)
    private String code;

    @Comment("图标")
    private String icon;

    @Comment("所属商品")
    @FieldName
    @FieldConvert
    @FormField(title = "商品", type = InputType.select, option = "product")
    @ManyToOne(fetch = FetchType.LAZY)
    private Product product;

    @Comment("销售价格")
    @FormField(title = "价格", grid = true, required = true)
    @Column(precision = 10, scale = 2)
    private BigDecimal price;

    @Comment("标准价(原价)")
    @FormField(title = "标准价", grid = true, required = true)
    @Column(precision = 10, scale = 2)
    private BigDecimal  standardPrice;

    @Comment("库存数量")
    @FormField(title = "库存", grid = true)
    private Integer stock;

    @Comment("实时库存")
    @FormField(title = "即时库存", grid = true)
    private Integer realStock;

    @Comment("SKU说明")
    @FormField(title = "备注", type = InputType.textarea)
    @Column(length = 500)
    private String note;
}
